/**
 * 
 */

$(function(){
	 
		$('.icon_name').val( $('.selectpicker').find("option:selected").text());
		$('.icon_password').val('12345678');
		$('.selectpicker').selectpicker('hide')
		$('.icon_name').focus(function(){
			$('.selectpicker').selectpicker('show')
			
		});
		$('.selectpicker').change(function(){
			var name = $('.selectpicker').find("option:selected").text();
			var sfzhm = $('.selectpicker').val();
			$('.icon_name').val(name);
	 		if("913201187245953450"==sfzhm){
				$('.icon_password').val('123456');
	 		}else{
	 			$('.icon_password').val('12345678');
	 		}
			$('.selectpicker').selectpicker('hide');
		});
		
		$('.btn_login').click(function(){
			$.ajax({
				  type: 'POST',
				  async:false,
				  url: '../user/login',
				  contentType : 'application/json',
				  data:JSON.stringify({"userId":$(".selectpicker").val(),"password":$(".icon_password").val(),"userName":$(".selectpicker").find("option:selected").text()}),
				  dataType: 'json',
				  success: function(data){
					  window.location.href = "index.html";
				  },
				  error:function(data){
					  console.log("error:"+JSON.stringify(data));
					  $('.selectpicker').selectpicker('refresh');
				  }
			})
		});
		
		$('.btn_sendMessage').click(function(){
			$.ajax({
				type: 'POST',
				async:false,
				url: '../share/sendMessage',
				contentType : 'application/json',
				data:JSON.stringify({"phone":$("#phone").val(),"message":$("#message").val()}),
				dataType: 'json',
				success: function(data){
					alert(data.info);
				},
				error:function(data){
					console.log("error:"+JSON.stringify(data));
					$('.selectpicker').selectpicker('refresh');
				}
			})
		});
	})